<template>
  <div>
    <div class="think-box" v-if="movieData">
      <div class="hd">
        <comp-sousuo>
          <template v-slot:text>
            <p>没有接口，只能用ID了</p>
          </template>
        </comp-sousuo>
      </div>
      <div class="think-list">
        <ul>
          <li v-for="(e, i) in thinkId" @click="jumpDetail(e)" :key="i">
            {{ e }}
          </li>
        </ul>
      </div>
      <!-- 内容区 -->
    </div>
  </div>
</template>

<script>
import compSousuo from "../components/comp-sousuo.vue";
export default {
  name: "think",
  components: { compSousuo },
  data() {
    return {
      thinkId: [],
      movieData: [],
      loadState: -1,
    };
  },
  beforeRouteEnter(to, from, next) {
    if (localStorage.getItem("token")) {
      next();
    } else {
      next("/login");
    }
  },
  methods: {
    getLikeData(t) {
      this.loadState = false;
      let pro = axios.get("index/moreComingList", {
        params: {
          // ci: 1,
          limit: 2,
          movieIds: t,
        },
      });
      pro
        .then((res) => {
          // setTimeout(() => {
          //   this.loadState = true;
            console.log(res);
            this.movieData = res.coming;
            console.log(res.coming);
          // }, 1000);
        })
        .catch((err) => {
          console.log("请求失败----->", err);
        });
    },
    getData(k) {
      this.loadState = false;
      let pro = axios.get("index/moreComingList", {
        params: {
          movieIds:k
        },
      });
      pro
        .then((res) => {
          console.log(res);
        })
        .catch((err) => {
          console.log("请求失败----->", err);
        });
    },
    explain(k) {
      for (let i = 0; i < k.length; i++) {
        // console.log(k[i].like_id);
        this.thinkId.push(k[i].like_id);
      }
      // this.getData( this.thinkId)
      // this.getLikeData( this.thinkId)
      console.log(this.thinkId);
    },
    jumpDetail(k) {
      // console.log(k);
      this.$router.push({ path: "/detail", query: { id: k } });
    },
  },
  created() {
    let k = this.$store.state.allLikeid.result;
    this.explain(k);
  },
  mounted() {
    // console.log(this.$store.state.allLikeid.result);
  },
};
</script>

<style lang="scss" scoped>
.think-box {
  width: 100%;
  height: 100%;
  position: fixed;
  background: linear-gradient(to bottom, #2c3e50, #bdc3c7);
}
.think-list {
  margin-top: 68px;
  ul {
    li {
      width: 100%;
      border: 1px solid #ccc;
      margin: 10px auto;
      color: #fff;
      text-align: center;
      padding: 10px 0;
    }
  }
}
</style>